/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tags.customs;

import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

/**
 *
 * @author NHAnh
 */
public class TemplateTag extends TagSupport {

   private String title;
   private String header; 
   private String mainContent;  
   private String footer;

   public void setFooter(String footer) {
      this.footer = footer;
   }

   public void setHeader(String header) {
      this.header = header;
   }

   public void setMainContent(String mainContent) {
      this.mainContent = mainContent;
   }

   public void setTitle(String title) {
      this.title = title;
   }

   @Override
   public int doStartTag() {
      JspWriter out = this.pageContext.getOut();
      try {
      out.println("<html>");   
    out.println("<head>");
    out.println(" <meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>");   
    out.println(" <title>"+title+"</title>");   
    out.println(" <link href='css/stylesheet.css' rel='stylesheet' />");    
   out.println("<link href='css/carousel.css' rel='stylesheet' />"); 
   
 
   out.println("<script type='text/javascript' src='javascript/jquery/jquery-1.7.1.min.js' ></script>");
   out.println("<script type='text/javascript' src='javascript/jquery/jquery-ui-1.8.16.custom.min.js' ></script>");   
   out.println("<script type='text/javascript' src='javascript/jquery/tabs.js' ></script>");
   out.println("<script type='text/javascript' src='javascript/jquery/jquery.form.js' ></script>");
   out.println("<link type='text/css' href='javascript/jquery/ui/themes/ui-lightness/jquery-ui-1.8.16.custom.css' rel='stylesheet' />");
   
   out.println("<link href='css/js_slideshow.css' rel='stylesheet' />"); 
   out.println("<link href='css/jquery.countdown.css' rel='stylesheet' />"); 
   out.println("<script type='text/javascript' src='javascript/jquery/jquery_slideshow.js' ></script>");
   out.println("<script type='text/javascript'>"); 
   out.println("$(function(){");     
    out.println("$('#faded').faded({");            
    out.println("  speed: 500,");                  
     out.println(" crossfade: false,");                  
     out.println("autopagination:false,");                   
      out.println("      autoplay: 5000");            
      out.println("});  ");                     
      out.println("});");  
        
   out.println("</script>"); 
   
   out.println("<script type='text/javascript' src='javascript/jquery/jquery.countdown.js'></script>");
    ////////////////
    out.println ("<script type='text/javascript' src='http://maps.googleapis.com/maps/api/js?sensor=false&language=vi'></script>");
    out.println ("    <script type='text/javascript'>");
    out.println ("        var map;");
    out.println ("        function initialize() {");
    out.println ("            var myLatlng = new google.maps.LatLng(10.843928,106.717672);");
    out.println ("                var myOptions = {");
    out.println ("                zoom: 16,");
    out.println ("                center: myLatlng,");
    out.println ("                mapTypeId: google.maps.MapTypeId.ROADMAP");
    out.println ("            }");
    out.println ("            map = new google.maps.Map(document.getElementById('googlemap'), myOptions); ");
    out.println ("            var text;");
    out.println ("            text= 'ABC';");
    out.println ("            var infowindow = new google.maps.InfoWindow({ ");
    out.println ("                content: text,");
    out.println ("                size: new google.maps.Size(100,50),");
    out.println ("                position: myLatlng");
    out.println ("            });");
    out.println ("            infowindow.open(map);    ");
    out.println ("            var marker = new google.maps.Marker({");
    out.println ("                position: myLatlng, ");
    out.println ("                map: map,");
    out.println ("                title:'Trường ĐH GTVT TP.HCM!'");
    out.println ("            });");
    out.println ("        }");
    out.println ("    </script>");

   /////////////////
   //out.println("<script type='text/javascript' src='javascript/jquery/carousel.js'></script>"); 
   
   out.println(" </head>");
  out.println(" <body onload='initialize();'>"); 
          this.pageContext.include(header);
          this.pageContext.include(mainContent);
          this.pageContext.include(footer);
  out.println("</body>");  
out.println("</html>");
      } catch (IOException ex) {
         Logger.getLogger(TemplateTag.class.getName())
                 .log(Level.SEVERE, null, ex);
      } catch (ServletException ex) {
         Logger.getLogger(TemplateTag.class.getName())
                 .log(Level.SEVERE, null, ex);

      }
      return SKIP_BODY;
   }
   @Override
   public int doEndTag(){
      return EVAL_PAGE;
   }
   @Override
   public void release(){
      this.title=null;
      this.header=null;   
      this.mainContent=null;
      this.footer=null;
   }
}
